﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _16_01_2013
{
    class MangHaiChieu
    {
        static int i, j, c, r;
        static int[,] a;
        //int[,] mArray = new int[2, 4]{ 
        //        {2,2,2,2}, 
        //        {3,3,3,3}, 
        //    }; 
        public static void NhapLieu()
        {
            Console.Write("Nhap vao so cot cua mang: ");
            c = Convert.ToInt32(Console.ReadLine());
            Console.Write("Nhap vao so dong cua mang: ");
            r = Convert.ToInt32(Console.ReadLine());
            a = new int[c, r];
            for (i = 0; i < c; i++)
            {
                for (j = 0; j < r; j++)
                {
                    Console.Write("\n a[{0},{1}]: ", i, j);
                    a[i, j] = Convert.ToInt32(Console.ReadLine());

                }
            }
        }
        public static void Xuat()
        {
            for (i = 0; i < c; i++)
            {
                for (j = 0; j < r; j++)
                {
                    Console.WriteLine("Gia tri cua [{0},{1}]: {2}", i, j, a[i, j]);
                }
            }
        }
        public int Max()
        {
            int max;
            max = a[0, 0];
            for (i = 0; i < c; i++)
            {
                for (j = 0; j < r; j++)
                {
                    if (max < a[i, j])
                    {
                        max = a[i, j];
                    }
                }
            }
            return max;
        }

        public int Min()
        {
            int min;
            min = a[0, 0];
            for (i = 0; i < c; i++)
            {
                for (j = 0; j < r; j++)
                {
                    if (a[i, j] < min)
                    {
                        min = a[i, j];
                    }
                }
            }
            return min;
        }
    }
}
